In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
In the dark basement of chemistry professor Acidrain's house there are two drawers with gloves - one with left hand and other with right hand gloves. In each of them there are gloves of different colours. Professor knows how many gloves of each colour there are in each drawer (the number of gloves of the same colour may differ in both drawers). He is also sure that it is possible to find a pair of gloves of the same colour.
Professor's experiment may be successful only if he uses gloves of the same colour (it does not matter which one), so before every experiment he goes to the basement and takes gloves from the drawers hoping that there will be at least one pair of the same colour. It is so dark in the basement that there is no possibility to recognize colour of any glove without going out of the basement. Professor hates going to the basement more than once (in case there was no pair of gloves of the same colour), as well as bringing unnecessarily large amounts of gloves to the laboratory.
Write a program that:
The first line of the standard input contains one positive integer () describing the number of distinct colours. The colours are numbered from 1 to . The second line of input contains non-negative integers , where corresponds to the number of gloves of colour number in the drawer with left hand gloves. Finally, the third line of input contains non-negative integers , where corresponds to the number of gloves of colour number in the drawer with right hand gloves.
Additionally, in test cases worth of points, and .
The first line of the standard output should contain a single integer - the number of gloves which must be taken from the drawer with left hand gloves. The second line of output should contain a single integer - the number of gloves which must be taken from the drawer with right hand gloves. The sum of these two numbers should be as small as possible. If there are several correct results, your program should output any of them.
For the input data:
4 0 7 1 6 1 5 0 6
the correct result is:
2 8
Task author: Martins Opmanis.